package channel;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import database.Database;


public class ChannelGetPic {
	
	public static String getPic(int cid) {
		String pic = null;
		try {
			Connection con = Database.getConnection();
			Statement stmt = con.createStatement();

			ResultSet rs = stmt.executeQuery(String.format(
						"select pic_url " +
						"from channel " +
						"where id = %d",
						cid));
			
			if ( rs.next() ) {
				pic = rs.getString("pic_url");
			}
			
			stmt.close();
			con.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return pic;
	}

	public static String getTag(int cid) {
		String tag = null;
		try {
			Connection con = Database.getConnection();
			Statement stmt = con.createStatement();

			ResultSet rs = stmt.executeQuery(String.format(
						"select tag " +
						"from channel " +
						"where id = %d",
						cid));
			
			if ( rs.next() ) {
				tag = rs.getString("tag");
			}
			
			stmt.close();
			con.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return tag;
	}
}
